using Microsoft.AspNetCore.Mvc;
using ZeroBlog.Application.Rumours;
using ZeroBlog.Application.Rumours.Dtos.In;
using ZeroBlog.Application.Rumours.Dtos.Out;
using ZeroBlog.Application.Rumours.Dtos.Query;
using ZeroSum.Models;

namespace ZeroBlog.Api.Controllers;

[ApiController]
[Route("[controller]/[action]")]
public class RumourController : ControllerBase
{
    private readonly IRumourApplicationService _applicationService;

    public RumourController(IRumourApplicationService applicationService)
    {
        _applicationService = applicationService;
    }

    [HttpGet]
    public async Task<PagedResponseModel<PageRumourDto>> Page([FromQuery] PageRumourQuery query)
    {
        return await _applicationService.Page(query);
    }

    [HttpPost]
    public async Task Add([FromBody] AddRumourDto dto)
    {
        await _applicationService.AddAsync(dto);
    }

    [HttpPost]
    public async Task Delete([FromBody] DeleteRumourDto dto)
    {
        await _applicationService.DeleteAsync(dto);
    }

    [HttpPost]
    public async Task Update([FromBody] UpdateRumourDto dto)
    {
        await _applicationService.UpdateAsync(dto);
    }

    [HttpGet]
    public async Task<DetailRumourDto> Detail([FromQuery] DetailRumourQuery query)
    {
        return await _applicationService.Detail(query);
    }
}